import Vue from 'vue';
import Router from 'vue-router';
import store from '../store/index';
import * as ui from "ui";
const {API:{Message,LoadingBar}}=ui;
Vue.use(Router);
import routes from "./router";
const router = new Router({
    //mode: 'history',
    routes
}); 
router.beforeEach((to, from, next) => {
    window.scroll(0, 0);
    if (to.matched.some(record => record.meta.requiresAuth)) {
      if (!store.getters.getStatus) {
          Message.info('请登录！');
          return next({
              path: '/login',
              query: { redirect: to.fullPath }
          })
      }
    }
    LoadingBar.start();
    next() // 确保一定要调用 next()
})
router.afterEach(transition => {
    LoadingBar.finish();
});
export default router;



